package com.atguigu.order.Intercepter;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;

@Component//如果放入IOC容器就会自动注册拦截器，可以不做后面的注册
public class XTokenRequestInterceptor implements RequestInterceptor {
    /**
     *请求拦截器
     *template 请求模板
     */
    @Override
    public void apply(RequestTemplate template) {
        System.out.println("XTokenRequestInterceptor.......");
        template.header("X-Token", "UUID.randomUUID.toString()"); // 添加请求头，用作身份验证
    }
}
